class CreateAnswers < ActiveRecord::Migration
  def self.up
    create_table :answers do |t|
      t.text :description, :null => false
      t.date :delivered_at, :null => false
      t.decimal :correction_value, :defalut => 0.0, :null => false
      t.references :answer_content
      t.references :user, :null => false
      t.references :task, :null => false

      t.timestamps
    end
    add_index(:answers, [:user_id, :task_id], :unique => true, :name => "uk_student_task")
  end

  def self.down
    drop_table :answers
  end
end
